<?PHP
	if(!defined('APP_REPORT_ERRORS')){
			define('APP_REPORT_ERRORS', 'E_ERROR,E_WARNING,E_NOTICE,E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE');
	}
	
	import("error.Logger");
	class Error {
		function create($message,$file=__FILE__,$line=__LINE__){
			trigger_error("$message ($file line $line)",E_USER_ERROR);
		}
		function display($message){
			
		}
	}
	class ErrorReporter {
		function handler($errno, $errstr, $errfile, $errline){
			global $app;
			$errorcode = array();
			$errorcode[1] = "E_ERROR";
			$errorcode[2] = "E_WARNING";
			$errorcode[4] = "E_PARSE";
			$errorcode[8] = "E_NOTICE";
			$errorcode[16] = "E_CORE_ERROR";
			$errorcode[32] = "E_CORE_WARNING";
			$errorcode[64] = "E_COMPILE_ERROR";
			$errorcode[128] = "E_COMPILE_WARNING";
			$errorcode[256] = "E_USER_ERROR";
			$errorcode[512] = "E_USER_WARNING";
			$errorcode[1024] = "E_USER_NOTICE";
			$errorcode[6143] = "E_ALL";
			$errorcode[2048] = "E_STRICT";
			$errorcode[4096] = "E_RECOVERABLE_ERROR";
			$parsed = false;
			if(in_array($errorcode[$errno],explode(",",APP_REPORT_ERRORS))){
				$error_level = 10;
				switch ($errno) {
					case E_ERROR:
					case E_USER_ERROR:
						$error_level = 0;
						break;
					case E_WARNING:
					case E_USER_WARNING:
						$error_level = 1;
						break;
					case E_NOTICE:
					case E_USER_NOTICE:
						$error_level = 2;
						break;
						$error_level = 0;
					default:
						$error_level = 0;
						break;
				}
				if(isset($app)){
					$app->onError($error_level,$errstr,$errfile,$errline);
					$parsed = true;
				}else{
					$parsed = false;
				}
			}
			return $parsed;
		}
		function init(){
			$old_error_handler = set_error_handler(array("ErrorReporter","handler"));
		}
	}
	ErrorReporter::init();
?>